package com.threader.bo;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Random;

import com.threader.utils.ConstantRegistry;


public class Passport {
	private final String[] sexCaption = {"Mail", "Femail"};
	
	public static final int MAIL = 0;
	public static final int FEMAIL = 1;
	
	private String seriya = "";
	private int number;
	private String firstName = "noname";
	private String lastName = "noname";
	private Integer sex;

	public long birthDay; 
		//35*365*24*60*60*1000;
	
	public Passport(String firstName, String lastName, Integer sex, GregorianCalendar age) {
		setBithday(age.getTimeInMillis());
		this.setFirstName(firstName);
		this.setLastName(lastName);
		this.setNumber(	 ConstantRegistry.ALPHABET[new Random().nextInt(ConstantRegistry.ALPHABET.length)]
						+ConstantRegistry.ALPHABET[new Random().nextInt(ConstantRegistry.ALPHABET.length)],
					  ""+(new Random().nextInt(9))
						+(new Random().nextInt(9))
						+(new Random().nextInt(9))
						+(new Random().nextInt(9))
						+(new Random().nextInt(9))
						+(new Random().nextInt(9))
						);
		this.setSex(sex);
	}

	public String toString() {
		return getFirstName() + " " + getLastName() + ", " + getSex() + ", "
				+ getNumber();
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setNumber(String s, String n) {
		seriya = s;
		number = new Integer(n);
	}

	public String getNumber() {
		return seriya +" "+ number;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	public String getSex() {
		return this.sexCaption[this.sex];
	}

	public void setBithday(long birthDay) {
		this.birthDay = birthDay;
	}

	public String getBithDay() {
		return new SimpleDateFormat("dd").format(new Date(this.birthDay))+" "+
			new SimpleDateFormat("MMM").format(new Date(this.birthDay))+" "+
			new SimpleDateFormat("yyyy").format(new Date(this.birthDay));
	}

}
